{extends file='layout/admin.html'}

{block name='title'}Manage Assets - Geek-Zoo CMS{/block}

{block name='content'}
    		<div class="clearfix sub_nav b_border"><span class="btn fr"><a href="admin/{$controller}.html">Cancel</a></span><span class="btn fr"><a href="admin/{$controller}/edit.html?id={$info.id}">Edit Asset</a></span></div>
    		<h3 class="pt10">Asset Detail</h3>
    		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="content_table">
    			<thead>
    				<tr style="height: 20px">
    					<th class="left"></th>
    					<th class="right"></th>
    				</tr>
    			</thead>
    			<tbody>
    				<tr>
    					<td style="width: 30%" class="left_label large tar">Title</td>
    					<td class="right_label">{$info.title}</td>
    				</tr>
    				<tr>
    					<td style="width: 30%" class="left_label large tar">Thumbnail image</td>
    					<td class="right_label">{if $info.img}<img src="pic/200/200?file={$info.img}">{/if}</td>
    				</tr>
    				<tr>
    					<td style="width: 30%" class="left_label large tar">Description</td>
    					<td class="right_label">{$info.description}</td>
    				</tr>
    				<tr>
    					<td style="width: 30%" class="left_label large tar">Tags</td>
    					<td class="right_label">{$info.tags}</td>
    				</tr>
						{foreach $tags as $key=>$val}
    				<tr>
    					<td style="width: 30%; height 60px;" class="left_label large tar">{$key}</td>
    					<td class="right_label">
    						{$val}
    					</td>
    				</tr>
						{/foreach}
						{foreach $info.append as $key=>$val}
						<tr>
    					<td style="width: 30%" class="left_label large tar">{$key}</td>
    					<td class="right_label">{$val}</td>
    				</tr>
						{/foreach}
    			</tbody>
    		</table>
    		<div class="clearfix sub_nav t_border"><span class="btn fr"><a href="admin/{$controller}.html">Cancel</a></span><span class="btn fr"><a href="admin/{$controller}/edit.html?id={$info.id}">Edit Asset</a></span></div>

<script type="text/javascript" charset="utf-8">
	
	var name_name = '';
	var name_id = '';
	
	$(".Add_Version").click(function(){
		var name = $("input[name=add_v]").val();
		$.getJSON("admin/{$controller}/ajax_add_version.html?asset_id={$info.id}&name="+name,function(data){
			if (!data) {
				show_msg('name is empty');
			}else{
				$(".assets_version_add").append('<tr view="1" vid="'+data.id+'">\
						<td>'+data.version_name+'</td>\
						<td style="border-right-style: none; border-right-width: initial; border-right-color: initial; ">'+data.files_num+'</td>\
						<td style="border-right-style: none; border-right-width: initial; border-right-color: initial; text-align: center;">'+data.add_time+'</td>\
						<td style="border-right-style: none; border-right-width: initial; border-right-color: initial; text-align: center;"><a href="admin/{$controller}/add_file.html?id='+data.id+'" class="pr10">Add File</a>|<a href="'+data.id+'" class="pr10 pl10 v_edit">Edit</a>|<a href="'+data.id+'" class="pl10 v_delete">Delete</a></td>\
						<td class="drag_area" style="border-right-style: none; text-align: center;"><img class="arrow" alt="Action menu" src="images/i.gif"></td>\
					</tr>');
			}; 
		});
		return false;
	});
	
	$(".v_edit").live("click", function(){
		var name = $('td:first', $(this).parents('tr:first'));
		name_name = name;
		var id = $(this).attr('href');
		name_id = id;
		$(".a_v_c").hide();
		$(".e_v_c").show();
		$("input[name=edit_v]").val(name.html());
		$("input[name=edit_v]").focus();
		return false;
	});
	
	$(".edit_cancel").click(function(){
		$(".a_v_c").show();
		$(".e_v_c").hide();
	});
	
	$(".edit_Version").click(function(){
		var name_1 = $("input[name=edit_v]").val();
			$.get('admin/{$controller}/ajax_edit_version.html?id='+name_id+'&name='+name_1, function(data){
				if (data == 'NULL') {
					show_msg('name is empty!');
				}else{
					name_name.html(data);
					$(".a_v_c").show();
					$(".e_v_c").hide();
				};
			});
	});
	
	$(".v_delete").live("click", function(){
		var name = $('td:first', $(this).parents('tr:first'));
		name_name = name;
		var id = $(this).attr('href');
		name_id = id;
		confirm('Are you sure to delete this?', function(){
				$.get('admin/{$controller}/ajax_delete_version.html?id='+name_id, function(data){
					if (data == 'NULL') {
						show_msg('not a asset!');
					}else{
						name_name.parent().remove();
					};
				});
		});
		return false;
	});

	function ajax_delete_related(id){
		confirm('Are you sure to delete this?', function(){
			$.get('admin/{$controller}/ajax_delete_related.html?id='+id, function(data){
					if (data=='0') {
						show_msg('delete failed');
					} else {
						 $('#delete_related_id_'+id).remove();
					};
			});
		});
		return false;
	}
</script>
{/block}
 